// main.cpp - 使用模块的主程序
import math_operations;  // 导入数学运算模块
import string_utils;     // 导入字符串工具模块

#include <iostream>
#include <vector>
#include <string>

int main() {
    std::cout << "=== C++20 模块示例 ===" << std::endl;
    
    // 使用数学运算模块
    std::cout << "\n--- 数学运算模块测试 ---" << std::endl;
    
    // 使用命名空间中的函数
    int sum = MathOps::add(10, 5);
    int diff = MathOps::subtract(10, 5);
    int product = MathOps::multiply(10, 5);
    double quotient = MathOps::divide(10.0, 5.0);
    
    std::cout << "基本运算结果:" << std::endl;
    std::cout << "10 + 5 = " << sum << std::endl;
    std::cout << "10 - 5 = " << diff << std::endl;
    std::cout << "10 * 5 = " << product << std::endl;
    std::cout << "10 / 5 = " << quotient << std::endl;
    
    // 使用导出的常量
    std::cout << "π 的值: " << MathOps::PI << std::endl;
    
    // 使用模板函数
    auto max_int = MathOps::max_value(15, 25);
    auto max_double = MathOps::max_value(3.14, 2.71);
    std::cout << "max(15, 25) = " << max_int << std::endl;
    std::cout << "max(3.14, 2.71) = " << max_double << std::endl;
    
    // 使用导出的类
    MathOps::Calculator calc("我的计算器");
    calc.add(100, 200);
    calc.subtract(300, 150);
    std::cout << "计算器名称: " << calc.get_name() << std::endl;
    
    // 使用字符串工具模块
    std::cout << "\n--- 字符串工具模块测试 ---" << std::endl;
    
    std::string text = "Hello World";
    std::cout << "原始文本: " << text << std::endl;
    std::cout << "转大写: " << StringUtils::to_upper(text) << std::endl;
    std::cout << "转小写: " << StringUtils::to_lower(text) << std::endl;
    
    // 字符串分割和连接
    std::string csv = "apple,banana,cherry,date";
    auto fruits = StringUtils::split(csv, ',');
    std::cout << "分割结果 (" << fruits.size() << " 个元素):" << std::endl;
    for (const auto& fruit : fruits) {
        std::cout << "  - " << fruit << std::endl;
    }
    
    std::string joined = StringUtils::join(fruits, " | ");
    std::cout << "重新连接: " << joined << std::endl;
    
    // 使用文本处理器类
    StringUtils::TextProcessor processor("处理器");
    std::cout << processor.process("这是一段测试文本") << std::endl;
    
    processor.set_prefix("新前缀");
    std::cout << processor.process("修改前缀后的文本") << std::endl;
    
    std::cout << "\n=== 模块示例完成 ===" << std::endl;
    return 0;
}
